package cn.gson.crm.model.service;

import cn.gson.crm.model.dao.CategoryDao;
import cn.gson.crm.model.mapper.CplbMapper;
import cn.gson.crm.model.pojos.Cate;
import cn.gson.crm.model.pojos.Category;
import cn.gson.crm.model.pojos.categ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class CplbService {
    @Autowired
    CategoryDao categoryDao;
    @Autowired
    CplbMapper cplbMapper;

    public List<Category> cx(String lbm){
        return cplbMapper.cx(lbm);
    }

    public List<Category> lei(Integer lbid){
        return cplbMapper.lei(lbid);
    }

    public List<Category> shanchu(){
        return cplbMapper.shanchu();
    }

    //新增类别
    public void cate(categ categ) {
        Category category = categ.getCategory();
        categoryDao.save(category);
    }

    //根据parentid查类别名
    public List<Category> lj(Integer idd){
        return cplbMapper.lj(idd);
    }

    //删除类别
    @Transactional(transactionManager = "transactionManager")
    public void shan(Integer categoryId){
        categoryDao.shan(categoryId);
    }

    //根据级别查询类别
    public List<Category> jl(){
        return cplbMapper.jl();
    }

    public List<Category> lj1(Integer iid){
        return cplbMapper.lj1(iid);
    }
}
